package org.shell.commands;

public abstract class Command implements Comparable {

    protected String commandName;
    protected static final String testCommandName = "^[a-zA-Z]+$";

    public String getCommandName() {
        return commandName;
    }

    protected boolean testCommandName(String test) {
        return test != null && test.matches(testCommandName);
    }

    public int compareTo(Object o) {
        if (o != null) {
            return -((Command)o).getCommandName().compareToIgnoreCase(getCommandName());
        }
        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof Command)) {
            return false;
        }
        final Command other = (Command) obj;
        if ((this.commandName == null) ? (other.commandName != null) : !this.commandName.equals(other.commandName)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 79 * hash + (this.commandName != null ? this.commandName.hashCode() : 0);
        return hash;
    }
}
